/*
 *
 *  Copyright (C) 2012-2024
 *  All rights reserved, Designed By 杭州连线客信息技术有限公司
 *  注意：
 *  本软件为杭州连线客信息技术有限公司开发研制，未经购买不得使用
 *  购买后可获得全部源代码（禁止转卖、分享、上传到码云、github等开源平台）
 *  一经发现盗用、分享等行为，将追究法律责任，后果自负
 *
 */

package com.lxk.oms.postorder.domain.enums;

import cn.hutool.core.collection.CollUtil;
import io.github.linpeilie.annotations.AutoEnumMapper;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Map;
import java.util.stream.Collectors;

/**
 * 售后订单枚举
 *
 * @author heyi
 * 2024/9/28
 */
public interface PostOrderEnums {


    /**
     * 类型 0=用户地址  10=商家地址
     */
    @AllArgsConstructor
    @Getter
    enum AddressType {
        USER(0, "用户地址"),
        SHOP(1, "商家地址"),
        ;

        private static final Map<Integer, AddressType> map = CollUtil.toList(AddressType.values()).stream().collect(Collectors.toMap(AddressType::getCode, v -> v));
        private final Integer code;
        private final String name;

        public static Boolean containCode(Integer code) {
            return map.containsKey(code);
        }

        public static AddressType getByCode(Integer code) {
            return map.get(code);
        }
    }
    /**
     * 货物状态 0=已收到货1=未收到货
     */
    @AllArgsConstructor
    @Getter
    public enum GoodStatus {
        YES(0, "已收到货"),
        NOT(1, "未收到货");

        private static final Map<Integer, GoodStatus> map = CollUtil.toList(GoodStatus.values()).stream().collect(Collectors.toMap(GoodStatus::getCode, v -> v));
        private final Integer code;
        private final String name;

        public static Boolean containCode(Integer code) {
            return map.containsKey(code);
        }

        public static GoodStatus getByCode(Integer code) {
            return map.get(code);
        }
    }


    /**
     * 售后类型 0=退款  10=退款退货 20=换货
     */
    @AllArgsConstructor
    @Getter
    @AutoEnumMapper("postOrderType")
    enum PostOrderType {
        REFUND(0, "退款"),
        REFUND_RETURN(10, "退款退货"),
        EXCHANGE(20, "换货");
        private static final Map<Integer, PostOrderType> map = CollUtil.toList(PostOrderType.values()).stream().collect(Collectors.toMap(PostOrderType::getPostOrderType, v -> v));
        private final Integer postOrderType;
        private final String name;

        public static Boolean containCode(Integer code) {
            return map.containsKey(code);
        }

        public static PostOrderType getByCode(Integer code) {
            return map.get(code);
        }
    }

    /**
     * 状态0=未售后 1=待审核 10=待退货 20=待换货  25=换货中 30=待退款   40=已完成  100=审核不通过
     */
    @AllArgsConstructor
    @Getter
    @AutoEnumMapper("postOrderStatus")
    enum PostOrderStatus {
        INIT(0, "未售后"),
        REVIEW(1, "待审核"),
        RETURNED(10, "待退货"),
        ING(20, "待换货"),
        PENDING_REFUND(30, "待退款"),
        COMPLETED(40, "已完成"),
        FAIL(100, "审核不通过"),
        ;
        private static final Map<Integer, PostOrderStatus> map = CollUtil.toList(PostOrderStatus.values()).stream().collect(Collectors.toMap(PostOrderStatus::getPostOrderStatus, v -> v));
        private final Integer postOrderStatus;
        private final String name;

        public static Boolean containCode(Integer code) {
            return map.containsKey(code);
        }

        public static PostOrderStatus getByCode(Integer code) {
            return map.get(code);
        }
    }
}
